package pl.koziolekweb.szkola.GDComponents;

// GD-Components/Komponenty.java
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Komponenty extends JFrame {

	private static final long serialVersionUID = 1L;

	public static void main(String[] args) {
        new Komponenty();
    }

    Komponenty() {
        super("KOMPONENTY");
        setDefaultCloseOperation(EXIT_ON_CLOSE);

          // to i tak default...
        setLayout(new BorderLayout());

        JPanel lower = new JPanel();
        lower.setLayout(new GridLayout(2,1,5,2));
        JTextField tup = new JTextField(30);
        JTextField tdn = new JTextField(30);
        tup.setText("To jest pierwsze pole tekstowe");
        tdn.setText("To jest drugie pole tekstowe");
        lower.add(tup);
        lower.add(tdn);
        add(lower,BorderLayout.SOUTH);

        JPanel upper = new JPanel();
        upper.setLayout(new FlowLayout());
        JButton b1 = new JButton("But1");
        JButton b2 = new JButton("But2");
        JButton b3 = new JButton("But3");
        JButton b4 = new JButton("But4");
        upper.add(b1); upper.add(b2);
        upper.add(b3); upper.add(b4);
        add(upper,BorderLayout.NORTH);

        JTextArea ja = new JTextArea(5,30);
        ja.setBackground(new Color(153,204,255));
        ja.setForeground(Color.RED);
        ja.setText("To\njest\nJ\nText\nArea\n!");
        JScrollPane sc = new JScrollPane(ja,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        sc.setBorder(
            BorderFactory.createLineBorder(Color.GREEN,4));
        add(sc,BorderLayout.CENTER);

        pack();
        setVisible(true);
    }
}
